package atguigu.crowd.mvc.handler;


import atguigu.crowd.service.dao.AdminService;
import atguigu.crowd.util.CrowdUtil;
import com.atguigu.crowd.config.Admin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
public class MyHandler {

    @Autowired
    private AdminService adminService;

    @RequestMapping(value = "/test/ssm.html")
    public ModelAndView getView() {
        ModelAndView mv = new ModelAndView();
        List<Admin> admins = adminService.getAll();
        mv.addObject("admins", admins);
        mv.setViewName("index");

        System.out.println(10 / 0);

        return mv;
    }

    @RequestMapping("ajax01.json")
    @ResponseBody
    public String ajax01(HttpServletRequest request) {
        boolean b = CrowdUtil.judgeRequestType(request);
        return String.valueOf(b);
    }
}
